package com.jsgt.greekfire.ui.gfc.adapter

import android.content.Context
import android.text.TextUtils
import android.widget.RelativeLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.jsgt.greekfire.R
import com.jsgt.greekfire.bean.MyOrderBean
import com.jsgt.greekfire.bean.MyUserAdBean
import com.jsgt.greekfire.common.util.TimeUtil
import com.jsgt.greekfire.ui.coin.ordermanagement.HistoricalOrdersBean

class UserAdAdapter (
    context: Context,
    layoutId: Int,
    data: MutableList<MyOrderBean.ListBean>? = null
) : BaseQuickAdapter<MyOrderBean.ListBean, BaseViewHolder>(layoutId, data) {
    override fun convert(helper: BaseViewHolder, item: MyOrderBean.ListBean) {
        item?.let {
            if (!TextUtils.isEmpty(item?.createTime)){
                var time = TimeUtil.dealDateFormat(item?.createTime)
                if (!TextUtils.isEmpty(time)) {
                    helper.setText(R.id.tvTime, time)
                }else{
                    helper.setText(R.id.tvTime, item?.createTime)
                }
            }
            helper.setText(R.id.tvCurrency, item?.coinCode)
                .setText(R.id.tvCurrency1, "/USDT")
                .setText(
                    R.id.tvPrice,
                    context.resources.getString(R.string.historical_order_text3) + " " + item.dealAmount
                )
                .setText(
                    R.id.tvNum,
                    context.resources.getString(R.string.coinList_text3) + " " + item.dealNum
                )
                .setText(R.id.tvTotal, item?.totalAmount.toString())
            helper.setText(R.id.tvStatus, context.resources.getString(R.string.otc_text_order_completed))
            helper.setTextColor(R.id.tvStatus, context.resources.getColor(R.color.otc_order_text_999999))
            if (item?.dealType == 1) {
                helper.setImageResource(R.id.ivType, R.mipmap.otc_order_sell)
                helper.setTextColor(R.id.tvCurrency, context.resources.getColor(R.color.otc_order_text_EF7149))
            } else {
                helper.setImageResource(R.id.ivType, R.mipmap.otc_order_buy)
                helper.setTextColor(R.id.tvCurrency, context.resources.getColor(R.color.otc_order_text_07C087))
            }

        }
    }

}